<template>
  <div>
    <el-card :body-style="{padding:'15px'}" shadow="never">
      <el-radio-group v-model="activeName" size="medium">
        <el-radio-button :label="1" v-if="$permiss[1667]">{{ $t('团队数据') }}</el-radio-button>
        <el-radio-button :label="0">{{ $t('个人数据') }}</el-radio-button>
      </el-radio-group>
      <el-select style="width:200px;margin: 0 15px" :placeholder="$t('请选择APP')" clearable v-model="productName"
      >
        <el-option v-for="item in productList" :key="item.productId" :label="item.appName"
                   :value="item.productName"></el-option>
      </el-select>
      <el-select v-show="$permiss[1661]" style="width:200px;" v-model="guestGroupId"  :placeholder="$t('客群名称')">
        <el-option v-for="item in guestGroupList" :key="item.guestGroupId" :label="item.guestGroupName"
                   :value="item.guestGroupId"></el-option>
      </el-select>
    </el-card>
    <div style="margin-top: 15px">
      <PersonalData v-if="activeName === 0" :productName="productName" :guestGroupId="guestGroupId"/>
      <TeamData v-else :productName="productName" :guestGroupId="guestGroupId"/>
    </div>
  </div>
</template>

<script>
import PersonalData from "./personalData"
import TeamData from "./teamData"
import {selectProduct} from "@/api/system";
import {guestGroupList} from "@/api/postLoan";
export default {
  name: "index",
  components: {
    PersonalData,
    TeamData
  },
  data() {
    return {
      activeName: 1,
      productList: [],
      productName: null,
      type: 1,
      guestGroupId: null,
      guestGroupList: []
    }
  },

  mounted() {
    if (this.$permiss[1667]) {
      this.activeName = 1
    } else {
      this.activeName = 0
    }
    guestGroupList({
      pageNum: 1,
      pageSize: 1000,
      type: 1
    }).then(res => {
      const {list} = res.data
      this.guestGroupList = list || []
      if (this.guestGroupList.length > 0) this.guestGroupId =  this.guestGroupList[0].guestGroupId
    })
    selectProduct().then(res => {
      this.productList = res.data
    })
  },
  methods: {}
}
</script>

<style scoped>

</style>
